package me.jiatao.paging3

import android.content.Intent
import android.os.Bundle
import android.view.View
import android.widget.Toast
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.launch
import me.jiatao.paging3.network.ProjectHttpViewModel

class HomeActivity : AppCompatActivity() {

//    private val projectViewModel by viewModels<ProjectHttpViewModel>()



    private val remoteKeysDao = MyApplication.getDB().remoteKeysDao()
    private val articleDao = MyApplication.getDB().articleDao()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_home)



        lifecycleScope.launch {
//            MyApplication.getDB().articleDao().deleteAll()
            remoteKeysDao.getRemoteKeys("")
            articleDao.deleteAll()
        }

    }

    fun gotoMain(view: View) {

        startActivity(Intent(this, MainActivity::class.java))

//        projectViewModel.projectPageLiveData.observe(this, {
//            it.datas?.forEach(::println)
//        })
    }
}